package com.ruoyi.web.controller.fantasy;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.huanzhidadi.fantasy.bean.domain.FantasyTaskReward;
import com.ruoyi.fantasy.service.IFantasyTaskRewardService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 任务奖励关系 信息操作处理
 * 
 * @author wanghui
 * @date 2019-07-05
 */
@Controller
@RequestMapping("/fantasy/fantasyTaskReward")
public class FantasyTaskRewardController extends BaseController
{
    private String prefix = "fantasy/fantasyTaskReward";
	
	@Autowired
	private IFantasyTaskRewardService fantasyTaskRewardService;
	
	@RequiresPermissions("fantasy:fantasyTaskReward:view")
	@GetMapping()
	public String fantasyTaskReward()
	{
	    return prefix + "/fantasyTaskReward";
	}
	
	/**
	 * 查询任务奖励关系列表
	 */
	@RequiresPermissions("fantasy:fantasyTaskReward:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FantasyTaskReward fantasyTaskReward)
	{
		startPage();
        List<FantasyTaskReward> list = fantasyTaskRewardService.selectFantasyTaskRewardList(fantasyTaskReward);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出任务奖励关系列表
	 */
	@RequiresPermissions("fantasy:fantasyTaskReward:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FantasyTaskReward fantasyTaskReward)
    {
    	List<FantasyTaskReward> list = fantasyTaskRewardService.selectFantasyTaskRewardList(fantasyTaskReward);
        ExcelUtil<FantasyTaskReward> util = new ExcelUtil<FantasyTaskReward>(FantasyTaskReward.class);
        return util.exportExcel(list, "fantasyTaskReward");
    }
	
	/**
	 * 新增任务奖励关系
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存任务奖励关系
	 */
	@RequiresPermissions("fantasy:fantasyTaskReward:add")
	@Log(title = "任务奖励关系", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(FantasyTaskReward fantasyTaskReward)
	{		
		return toAjax(fantasyTaskRewardService.insertFantasyTaskReward(fantasyTaskReward));
	}

	/**
	 * 修改任务奖励关系
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		FantasyTaskReward fantasyTaskReward = fantasyTaskRewardService.selectFantasyTaskRewardById(id);
		mmap.put("fantasyTaskReward", fantasyTaskReward);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存任务奖励关系
	 */
	@RequiresPermissions("fantasy:fantasyTaskReward:edit")
	@Log(title = "任务奖励关系", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(FantasyTaskReward fantasyTaskReward)
	{		
		return toAjax(fantasyTaskRewardService.updateFantasyTaskReward(fantasyTaskReward));
	}
	
	/**
	 * 删除任务奖励关系
	 */
	@RequiresPermissions("fantasy:fantasyTaskReward:remove")
	@Log(title = "任务奖励关系", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(fantasyTaskRewardService.deleteFantasyTaskRewardByIds(ids));
	}
	
}
